package top.api.mapper;

import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import top.api.domain.entity.Category;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.util.List;

/**
* @author 27465
* @description 针对表【sg_category(分类表)】的数据库操作Mapper
* @createDate 2023-01-29 12:39:19
* @Entity top.api.domain.entity.Category
*/
@Repository
public interface CategoryMapper extends BaseMapper<Category> {
    /**
     * 获取分类列表数据 要求：文章列表为正式文章且未删除(去重),分类列表正常且未删除
     * @return
     */
    @Select("SELECT id,name,pid,description,status,create_by,create_time,update_by,update_time,del_flag from sg_category WHERE (`status` = \"0\" and del_flag = 0) and id IN (SELECT DISTINCT category_id from sg_article WHERE (`status` = \"0\" and del_flag = 0));")
    List<Category> getCategoryList();
}




